<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014 1010422715@qq.com All rights reserved.
// +----------------------------------------------------------------------
// | author 烟消云散 <1010422715@qq.com>
// +----------------------------------------------------------------------

namespace Admin\Controller;

use Think\Page;

class ShowsController extends AdminController
{
    public function index($p = 1)
    {
        $page_size = 15;
        $count = M('ConcertLists')->count();
        $page = new Page($count, $page_size);
        $list = M('ConcertLists')->page($p . ',' . $page_size)->order("id desc")->select();
//        $list = M('ConcertLists')->page($p.','.$page_size)->order("create_time desc")->select();
        $this->assign('list', $list);
        $this->assign('_page', $page->show());
//        dump($list);
        $this->display();
    }


    public function detail($id = null)
    {
        $concertDetail = M('ConcertLists')->where("id='$id'")->find();
        $document = M('Document')->where("id=" . $concertDetail['cid'])->find();
        $concert = M('DocumentConcert')->where("id=" . $concertDetail['cid'])->find();
        $this->assign('detail', $concertDetail);
        $this->assign('info', $document);
        $this->assign('concert', $concert);
        $this->display();
    }


    public function act($id = 0, $s = 0)
    {
        if ($id && ($s == 0 || $s == 1)){
            $res = M('ConcertLists')->where("id='$id'")->save(array("status" => $s));
            if ($res){
                $this->success("状态修改成功!",U('index'));
            }else{
                $this->error("状态修改失败!",U('index'));
            }
        }else{
            $this->error("操作失败!",U('index'));
        }
    }


    public function del($id = 0)
    {
        if ($id){
            $res = M('ConcertLists')->where("id='$id'")->delete();
            if ($res){
                $this->success("删除成功!",U('index'));
            }else{
                $this->error("删除失败!",U('index'));
            }
        }else{
            $this->error("操作失败!",U('index'));
        }
    }

}